package com.maybach.web.framework.util;

/**
 * Created by houenxun on 16/1/19.
 * 扩展位运算
 */
public class MathTool  extends org.apache.velocity.tools.generic.MathTool{
    /**
     * 按位与
     * @param num1
     * @param num2
     * @return
     */
    public Number bitAnd(Object num1, Object num2) {
        Number n1 = this.toNumber(num1);
        Number n2 = this.toNumber(num2);
        return n1.longValue() & n2.longValue();
    }

    /**
     * 按位或
     * @param num1
     * @param num2
     * @return
     */
    public Number bitOr(Object num1, Object num2) {
        Number n1 = this.toNumber(num1);
        Number n2 = this.toNumber(num2);
        return n1.longValue() | n2.longValue();
    }
}
